package cn.z2huo.demo.log.aop.web.service.impl;

import cn.z2huo.core.util.IdUtils;
import cn.z2huo.demo.log.aop.web.service.OperateLogService;
import cn.z2huo.demo.mapper.system.OperateLogMapper;
import cn.z2huo.demo.model.dataobject.system.OperateLogDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *
 * @author z2huo
 */
@Service
public class OperateLogServiceImpl implements OperateLogService {

    @Autowired
    private OperateLogMapper operateLogMapper;

    @Transactional
    @Override
    public void insertLog(OperateLogDO operateLogDO) {
        if (operateLogDO == null) {
            throw new IllegalArgumentException("operateLogDO is null");
        }
        operateLogDO.setId(IdUtils.nextId());
        operateLogMapper.insertSelective(operateLogDO);
    }

    @Async
    @Transactional
    @Override
    public void insertLogAsync(OperateLogDO operateLogDO) {
        this.insertLog(operateLogDO);
    }

}
